package com.lzc.camera.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzc.camera.entity.Config;
import com.lzc.camera.mapper.ConfigMapper;
import com.lzc.camera.service.ConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lzc
 * @since 2022-11-20 08:54:54
 */
@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {

    @Autowired
    private ConfigMapper configMapper;

    @Override
    public List<Config> list(Config config, Integer pageSize, Integer pageNum) {
        QueryWrapper<Config> wrapper = new QueryWrapper<>();
        wrapper.isNotNull("id");
        if (config.getId() != null){
            wrapper.eq("id",config.getId());
        }
        if (!StringUtils.isEmpty(config.getIpAddress())){
            wrapper.eq("ip_address",config.getIpAddress());
        }
        if (!StringUtils.isEmpty(config.getPointKey())){
            wrapper.eq("point_key",config.getPointKey());
        }
        if (!StringUtils.isEmpty(config.getPointName())){
            wrapper.eq("point_name",config.getPointName());
        }
        List<Config> list = configMapper.selectList(wrapper);
        return list;
    }
}
